import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-09-21
 * Time: 9:26
 */
public class gather {
    public static void main(String[] args) {
        HashMap<Integer, String> map = new HashMap<>();
        map.put(1, "hello");
        map.put(2, "bit");
        map.put(3, "hello");
        map.put(4, "lambda");
//        map.forEach(new BiConsumer<Integer, String>() {
//            @Override
//            public void accept(Integer integer, String s) {
//                System.out.println("key:" + integer+"   " +"value:"+s);
//            }
//        });
        map.forEach(( integer, s)-> System.out.println("key:" + integer+"   " +"value:"+s));
    }




    public static void main1(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("fello");
        list.add("bit");
        list.add("hello");
//        list.forEach(new Consumer<String>() {
//            @Override
//            public void accept(String s) {
//                System.out.println(s);
//            }
//        });
        //list.forEach(s-> System.out.println(s));

//        list.sort(new Comparator<String>() {
//            @Override
//            public int compare(String o1, String o2) {
//                return o1.compareTo(o2);
//            }
//        });

        list.sort((o1,o2)->o1.compareTo(o2));
        list.forEach(s-> System.out.println(s));

    }
}
